import { storage } from "@/utils/Storage";
import { RouteObject } from "@/routers/types/router";
import { useDispatch, useSelector } from "react-redux";
import { setCurrentRoute } from "@/store/modules/global";
import { RootState } from "@/store";

const useRouter = () => {
	const dispatch = useDispatch();
	const setRouter = (router: any) => {
		// storage.set("currentRouter", router);
		dispatch(setCurrentRoute({ ...router }));
	};
	const getRouter = () => {
		// return storage.get("currentRouter");
		const { currentRoute } = useSelector((state: RootState) => state.global);
		return currentRoute;
	};

	return { setRouter, getRouter };
};

export default useRouter;
